Added an optional OAUTH_ALLOWED_ROLES environment variable#1463
Added an optional OAUTH_ALLOWED_ROLES environment variable#1463mattwoberts merged 18 commits intogetfider:mainfrom
Conversation
- Setting this prevents users without the specified roles from accessing the Fider instance Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
5d971d7 to
015c03d
Compare
Review: Design concern — global
|
|
@JimKnoxx Hi there - there's a couple of things there to look at - the jsonq thing i'd deffo look at for code duplication. If you do need any additional json stuff that might also be reusable then adding it to that package might be a good move too - rather than keeping it with the oauth stuff? |
- fixed duplication of jsonq code - fixed env var semicolon separator - added tests
|
@JimKnoxx I messed something up with the branch protection - so bear with me I'm sorting this now - you'll prb need to merge main back in when I've sorted it. EDIT: I think all sorted now - some of the GH workflows weren't running, it was me trying to make things faster (and breaking things) |
…r provider config - also fixed documentation URLS
|
The role definition should now be per provider. I also found some URLs that point nowhere - hope it's ok to fix it in this MR together with the improvements to the german translations. |
…romJSON Add Strings() and ArrayFieldStrings() methods to jsonq so that extractRolesFromJSON no longer needs direct encoding/json usage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@JimKnoxx I'm pretty happy with this I think - you happy with my last change? |
|
Yes! Looks good to me and works, thanks for taking the time and refactor it again. |
…rdless of the oauth role Co-Authored-By: Claude <noreply@anthropic.com>
|
I noticed 2 more things I wanna fix, just FYI:
|
|
@mattwoberts for the second problem: This means that if a role is removed in Fider, the change will be reflected immediately. However, if the user loses the role in the OAuth provider system during an active session, the change will not be detected immediately, and the user will still be able to use the system until they log in again. Do you have an idea for this? Or would you say, this is good enough? |
It feels like this is touching on some kind of security stamp type implementation. In .NET Core, there's a concept of a security stamp, which basically is a timestamp of the user's profile.If something changes, for example the user changes their password, then the security stamp is updated. At regular intervals, e.g., every 20 minutes. This is then checked and if it's changed, then the user is forced to log in again. So that might be something that would be worth doing. For example, if an admin changed their password on a different computer, it would then force a re-login on another computer that he might be logged in at. However, it doesn't really solve this problem because we would need to know about the change to their roles from the oauth provider. So you would need some way for the OAuth provider to tell Fider that the roles have changed. You could however use a security stamp type solution with your suggested change of checking the roles from the OAuth provider on every new login. It's not going to be as instant but other alternatives quickly start to look quite messy. |
|
@JimKnoxx getting my head around an april release, what's the status of this, is it something I should earmark for inclusion? |
…lowed roles change Co-Authored-By: Claude <noreply@anthropic.com>
|
Thank you for your feedback to the security stamps. |
|
@mattwoberts I think the server you ran tests against is offline? |
|
@JimKnoxx Not looked much at the code, just testing it a bit, and if you change your own name, it will log you out on the browser / session you're on - the idea is that the security stamp forces you to log in on all OTHER sessions, not the one that did the action... |
|
@mattwoberts I see, makes sense. |
…change Co-Authored-By: Claude <noreply@anthropic.com>
|
@mattwoberts Should work now as you intend |
|
@JimKnoxx Ah, it's still not working for me - I think the mismatch is because you're working from the perspective of the oauth change, and I'm testing from the perspective of a "normal" login. So currently, if you login and change your username, you're logged out since your security stamp session is lost. Thinking some more on this, I don't think a username / avatar change should really invalidate your security stamp. Typically on a "normal" app it would be role / password changes that would trip this. A name / avatar change shouldn't really affect the security stamp, so I'm going to remove this - let me know if you have an issue with that. |
Profile changes are not security-sensitive events and should not invalidate user sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@mattwoberts Oh, actually I never tested changing profile settings, so yeah! Good catch. That definitely also should not end the session! |
|
Ok I think this makes sense now... |
…s path no longer logs out users. Changing roles path with existing allowed roles will trigger a security stamp reroll. Co-Authored-By: Claude <noreply@anthropic.com>
|
@mattwoberts Noticed two more things:
|
|
@mattwoberts Checked your changes too and I think this is working good now. What do you think? |
mattwoberts
left a comment
There was a problem hiding this comment.
I think this is good to come in now
|
@JimKnoxx Ok I'll bring this in soon! |
We use Fider in a private instance with OAUTH as only login method.
We only want some users (teachers and admins) to access the instance.
At the moment we can only use "obscurity" measurements to prevent students from accessing.
In this PR I (and Claude), added the OAUTH_ALLOWED_ROLES .env variable, a way to filter out the roles from the oauth json response of a user and perform access checks based on the roles that the user has.
Issue: #1464
Generated with Claude Code